let strs = [""]
var groupAnagrams = function(strs) {
    if(strs.length<=0)return [strs]
    let result= []
    while(strs.length>0){
        let arr = []
        let one = strs.splice(0,1)
        arr.push(...one)
        for(let i=0;i<strs.length;i++){
            if(pan(...one,strs[i])){
                arr.push(...(strs.splice(i,1)))
                i--;
            }
        }
        result.push(arr)
    }
    return result
};

function pan(s,t){
        let arr = new Array(26).fill(0)
      for(let i=0;i<s.length;i++){
        arr[s[i].charCodeAt()-'a'.charCodeAt()] +=1
    }
    for(let j=0;j<t.length;j++){
        arr[t[j].charCodeAt()-'a'.charCodeAt()] -=1
    }
    for(let item of arr){
        if(item!==0){
            return false
        }
    }
        return true 
}
console.log(groupAnagrams(strs));

